<template>
  <div>
    <h3>小三组件</h3>
    <div>金钱：{{ $store.state.money }}</div>
    <div>金钱：{{ money }}</div>
    <button @click="buy">买包-50</button>
    <button @click="setNum">做头发-150</button>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  //   computed: {
  //     money() {
  //       return this.$store.state.money;
  //     },
  //   },
  computed: mapState(["money"]),
  methods: {
    buy() {
      //   this.$store.state.money -= 50;
      this.$store.commit("buy");
    },

    setNum() {
      this.$store.dispatch("doHairAsync", 150);
    },
  },
};
</script>

<style></style>
